package com.chaoxing.service.impl;

import com.chaoxing.entity.Charts;
import com.chaoxing.entity.Course;
import com.chaoxing.mapper.CourseMapper;
import com.chaoxing.service.CourseService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CourseServiceImpl implements CourseService {
    @Resource
    private CourseMapper courseMapper;

    @Override
    public int insertSelective(Course record) {
        return courseMapper.insertSelective(record);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return courseMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Course searchCourseNo(String courseno) {
        return courseMapper.searchCourseNo(courseno);
    }

    @Override
    public Course searchCourseName(String coursename) {
        return courseMapper.searchCourseName(coursename);
    }

    @Override
        //查询属于某个学院的课程
    public List<Course> searchCollegeCourses(String faculty,int index,int pageSize) {
        return courseMapper.searchCollegeCourses(faculty,index,pageSize);
    }

    @Override
    public List<Course> searchCollegeCurriculumCourses(String faculty, String coursename) {
        return courseMapper.searchCollegeCurriculumCourses(faculty, coursename);
    }

    @Override
    public List<Course> searchCollegeNoCourse(String faculty, String courseno) {
        return courseMapper.searchCollegeNoCourse(faculty, courseno);
    }

    @Override
    public int selectCourseNo(String courseno) {
        return courseMapper.selectCourseNo(courseno);
    }

    @Override
    public PageInfo<Course> queryCoursePage(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Course> lists = courseMapper.queryCoursePage();
        PageInfo<Course> pageInfo = new PageInfo<>(lists);
        return pageInfo;
    }

    @Override
    public List<Course> selectAllCourse(Integer pageNo, Integer pageSize) {
        return courseMapper.selectAllCourse(pageNo,pageSize);
    }

    @Override
    public int deleteCoursesByPrimaryKey(List<Integer> ids) {
        return courseMapper.deleteCoursesByPrimaryKey(ids);
    }

    @Override
    public List<Charts> queryAllIDByCourse() {
        return courseMapper.queryAllIDByCourse();
    }
}
